package it.polimi.swKnights.SWIMv2.servlets.administration;

import it.polimi.swKnights.SWIMv2.ejb.administration.AbilityToApproveRemote;
import it.polimi.swKnights.SWIMv2.general.WebsiteParameters;
import it.polimi.swKnights.SWIMv2.servlets.SwimServlet;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class AbilityRequestController
 */
public class SeeAbilityRequestController extends SwimServlet
{
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException
	{
		String destination = WebsiteParameters.seeAbilityRequestUrl;

		HttpSession session = request.getSession();
		String admin = (String) session.getAttribute("userName");
		String password = (String) session.getAttribute("password");

		AbilityToApproveRemote abilityRem = this
				.lookUp(AbilityToApproveRemote.class);

		Map<String, String> abilitiesMap = abilityRem.getAbilityToApprove(
				admin, password);

		request.setAttribute("requests", abilitiesMap);

		request.getRequestDispatcher(destination).forward(request, response);

	}
}
